 1.ClickHouse安装之下载地址
   
   官网：https://clickhouse.yandex/
   下载地址：http://repo.red-soft.biz/repos/clickhouse/stable/el6/
 
 2.单机模式
   
   1).上传4个文件到/opt/lagou/software/clickhouse_rpm
-rw-r--r--. 1 root root     6376 8月  14 2020 clickhouse-client-20.5.4.40-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 57490408 8月  14 2020 clickhouse-common-static-20.5.4.40-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 35102796 8月  14 2020 clickhouse-server-20.5.4.40-1.el7.x86_64.rpm
-rw-r--r--. 1 root root    12988 8月  14 2020 clickhouse-server-common-20.5.4.40-1.el7.x86_64.rpm
   2).分别安装这4个rpm文件
   rpm -ivh ./*.rpm
   */
   3).启动ClickServer
   前台启动：
   [root@linux121 ~]# sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-
server/config.xml
   后台启动：
   [root@linux121 ~]# nohup sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-
server/config.xml >null 2>&1 &
   4).使用client连接server
   [root@linux121 ~]# clickhouse-client -m
ClickHouse client version 20.5.4.40.
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 20.5.4 revision 54435.
linux121 :)

 3.分布式集群安装
   
   1).在linux122,linux123上面执行单机安装的所有步骤
   2).三台机器修改配置文件config.xml
   [root@hdp-1 ~]# vim /etc/clickhouse-server/config.xml
   注意点：
 <!-- Path to data directory, with trailing slash. -->
 <path>/var/lib/clickhouse/</path>
   zookeeper标签上面增加：
<include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
   3).在三台机器的/etc/clickhouse-server/config.d目录下新建metrika.xml文件
   [root@linux121 config.d]# vim metrika.xml
   添加如下内容：
   注意：标签中的内容对应自己的主机名   
<yandex>
	<clickhouse_remote_servers>
		<perftest_3shards_1replicas>
			<shard>
				<internal_replication>true</internal_replication>
				<replica>
					<host>linux121</host>
					<port>9000</port>
				</replica>
			</shard>
			<shard>
				<replica>
					<internal_replication>true</internal_replication>
					<host>linux122</host>
					<port>9000</port>
				</replica>
			</shard>
			<shard>
				<internal_replication>true</internal_replication>
				<replica>
					<host>linux123</host>
					<port>9000</port>
				</replica>
			</shard>
		</perftest_3shards_1replicas>
	</clickhouse_remote_servers>

	<zookeeper-servers>
		<node index="1">
			<host>linux121</host>
			<port>2182</port>
		</node>
		<node index="2">
			<host>linux122</host>
			<port>2182</port>
		</node>
		<node index="3">
			<host>linux123</host>
			<port>2182</port>
		</node>
	</zookeeper-servers>

	<macros>
		<shard>01</shard>
		<replica>linux121</replica>
	</macros>

	<networks>
		<ip>::/0</ip>
	</networks>

	<clickhouse_compression>
		<case>
			<min_part_size>10000000000</min_part_size>
			<min_part_size_ratio>0.01</min_part_size_ratio>
			<method>lz4</method>
		</case>
	</clickhouse_compression>
</yandex>

   注意：需要根据机器名字不同去修改 linux121
	<macros>
		<replica>linux121</replica>
	</macros>
   4).三台机器启动ClickServer
   首先在三台机器开启Zookeeper
   前台启动：
   [root@linux121 ~]# sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml
   注意：此方式为clickhouse官方提供的启动方式
   另外也可以：
   service clickhouse-server start或者systemctl start clickhouse-server方式启动
   几种方式首选官方提供的方式。 
   后台启动：
   [root@hdp-1 ~]# nohup sudo -u clickhouse clickhouse-server --config-file=/etc/clickhouse-server/config.xml
>null 2>&1 &   